// index.js
// 获取应用实例
const app = getApp();

Page({
  data: {
    hide: app.globalData.hide,
    navBarHeight: app.globalData.navBarHeight,
    menuRight: app.globalData.menuRight,
    menuBotton: app.globalData.menuBotton,
    menuTop: app.globalData.menuTop,
    menuHeight: app.globalData.menuHeight,
    active: 0,
    icon: {
      normal: "https://img.yzcdn.cn/vant/user-inactive.png",
      active: "https://img.yzcdn.cn/vant/user-active.png",
    },
    grid: [
      {
        id: 1,
        text: "鲜花",
        icon: "/static/icon/index/xianhua.png",
      },
      {
        id: 2,
        text: "蛋糕",
        icon: "/static/icon/index/dangao.png",
      },
      {
        id: 3,
        text: "面食",
        icon: "/static/icon/index/mianshi.png",
      },
      {
        id: 4,
        text: "雪糕",
        icon: "/static/icon/index/xuegao.png",
      },
      {
        id: 5,
        text: "水果",
        icon: "/static/icon/index/shuiguo.png",
      },
      {
        id: 6,
        text: "烧烤",
        icon: "/static/icon/index/shaokao.png",
      },
      {
        id: 7,
        text: "啤酒",
        icon: "/static/icon/index/pijiu.png",
      },
      {
        id: 8,
        text: "饮品",
        icon: "/static/icon/index/yinpin.png",
      },
    ],
    dayCheck: [
      {
        id: 1,
        goodsId: 1,
        title: "新品",
        imgUrl: "/static/images/logo.png",
        label: "New",
      },
      {
        id: 2,
        goodsId: 2,
        title: "折扣",
        imgUrl: "/static/images/swiper/3.png",
        label: "7折",
      },
      {
        id: 3,
        goodsId: 3,
        title: "测试",
        imgUrl: "/static/images/swiper/1.png",
        label: "",
      },
      {
        id: 4,
        goodsId: 0,
        title: "热销",
        imgUrl: "/static/images/logo.png",
        label: "Hot",
      },
    ],
    goodsList: [
      {
        id: 1,
        title: "商品1商品1商品1商品1商品1商品1商品1",
        detail:
          "详情详情详情详情详情详情详情详情详情详情详情详情详情详情详情详情详情详情详情详情详情详情",
        price: 99.99,
        img: "/static/images/logo.png",
      },
      {
        id: 2,
        title: "商品2",
        detail: "商品2详情商品2详情商品2详情商品2详情",
        price: 99.99,
        img: "/static/images/logo1.png",
      },
      {
        id: 3,
        title: "商品3",
        detail: "商品2详情商品2详情商品2详情商品2详情",
        price: 99.99,
        img: "/static/images/1.png",
      },
      {
        id: 4,
        title: "商品4",
        detail: "商品2详情商品2详情商品2详情商品2详情",
        price: 99.99,
        img: "/static/images/share.png",
      },
      {
        id: 5,
        title: "商品5",
        detail: "商品2详情商品2详情商品2详情商品2详情",
        price: 99.99,
        img: "/static/images/2.png",
      },
      {
        id: 6,
        title: "商品6",
        detail: "商品2详情商品2详情商品2详情商品2详情",
        price: 99.99,
        img: "/static/images/2.png",
      },
      {
        id: 7,
        title: "商品7",
        detail: "商品2详情商品2详情商品2详情商品2详情",
        price: 99.99,
        img: "https://i.imgtg.com/2023/06/29/OkJIel.png",
      },
      {
        id: 8,
        title: "商品8",
        detail: "商品2详情商品2详情商品2详情商品2详情",
        price: 99.99,
        img: "https://i.imgtg.com/2023/06/29/OkJ3Gg.png",
      },
    ],
  },
  // 事件处理函数
  onChange(event) {
    this.setData({ active: event.detail });
  },

  onPageScroll(e) {
    this.setData({
      scrollTop: e.scrollTop,
    });
  },

  showAddCartMask() {
    const that = this;
    wx.navigateTo({
      url: "/pages/detail/detail?showmask=true",
      success: (result) => {
        that.setData({ showMask: true });
      },
      fail: () => { },
      complete: () => { },
    });
  },

  onLoad() { },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() { },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() { },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() { },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() { },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() { },
  // 分享到朋友圈
  onShareTimeline() { },
});
